package com.ruoyi.web.controller.production.graftingclip;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.graftingclip.GraftingclipType;
import com.ruoyi.production.service.graftingclip.IGraftingclipTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 嫁接夹类型Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/graftingclipType")
public class GraftingclipTypeController extends BaseController
{
    @Autowired
    private IGraftingclipTypeService graftingclipTypeService;

    /**
     * 查询嫁接夹类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:graftingclipType:list')")
    @GetMapping("/list")
    public TableDataInfo list(GraftingclipType graftingclipType)
    {
        startPage();
        List<GraftingclipType> list = graftingclipTypeService.selectGraftingclipTypeList(graftingclipType);
        return getDataTable(list);
    }

    /**
     * 导出嫁接夹类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:graftingclipType:export')")
    @Log(title = "嫁接夹类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GraftingclipType graftingclipType)
    {
        List<GraftingclipType> list = graftingclipTypeService.selectGraftingclipTypeList(graftingclipType);
        ExcelUtil<GraftingclipType> util = new ExcelUtil<GraftingclipType>(GraftingclipType.class);
        return util.exportExcel(list, "嫁接夹类型数据");
    }

    /**
     * 获取嫁接夹类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:graftingclipType:query')")
    @GetMapping(value = "/{graftingclipTypeId}")
    public AjaxResult getInfo(@PathVariable("graftingclipTypeId") Long graftingclipTypeId)
    {
        return AjaxResult.success(graftingclipTypeService.selectGraftingclipTypeById(graftingclipTypeId));
    }

    /**
     * 新增嫁接夹类型
     */
    @PreAuthorize("@ss.hasPermi('production:graftingclipType:add')")
    @Log(title = "嫁接夹类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GraftingclipType graftingclipType)
    {
        return toAjax(graftingclipTypeService.insertGraftingclipType(graftingclipType));
    }

    /**
     * 修改嫁接夹类型
     */
    @PreAuthorize("@ss.hasPermi('production:graftingclipType:edit')")
    @Log(title = "嫁接夹类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GraftingclipType graftingclipType)
    {
        return toAjax(graftingclipTypeService.updateGraftingclipType(graftingclipType));
    }

    /**
     * 删除嫁接夹类型
     */
    @PreAuthorize("@ss.hasPermi('production:graftingclipType:remove')")
    @Log(title = "嫁接夹类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{graftingclipTypeIds}")
    public AjaxResult remove(@PathVariable Long[] graftingclipTypeIds)
    {
        return toAjax(graftingclipTypeService.deleteGraftingclipTypeByIds(graftingclipTypeIds));
    }
}
